<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"eryangz.gitee.io","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"mac"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="odoo实用配置与方法float字段管理 初始化小数decimal.precision记录，定义项目小数 float字段使用digits&#x3D;dp.get_precision(‘id’)获取初始化的小数，便于统一修改">
<meta property="og:type" content="article">
<meta property="og:title" content="odoo实用配置与方法">
<meta property="og:url" content="https://eryangz.gitee.io/20210605/odoo%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%96%B9%E6%B3%95/index.html">
<meta property="og:site_name" content="二扬">
<meta property="og:description" content="odoo实用配置与方法float字段管理 初始化小数decimal.precision记录，定义项目小数 float字段使用digits&#x3D;dp.get_precision(‘id’)获取初始化的小数，便于统一修改">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-06-05T13:02:56.000Z">
<meta property="article:modified_time" content="2023-05-20T09:05:32.943Z">
<meta property="article:author" content="二扬">
<meta property="article:tag" content="odoo">
<meta property="article:tag" content="笑脸交互">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://eryangz.gitee.io/20210605/odoo%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%96%B9%E6%B3%95/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>odoo实用配置与方法 | 二扬</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">二扬</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">blog</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://eryangz.gitee.io/20210605/odoo%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%96%B9%E6%B3%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="二扬">
      <meta itemprop="description" content="念念不忘, 必有回响">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="二扬">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          odoo实用配置与方法
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-06-05 21:02:56" itemprop="dateCreated datePublished" datetime="2021-06-05T21:02:56+08:00">2021-06-05</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-05-20 17:05:32" itemprop="dateModified" datetime="2023-05-20T17:05:32+08:00">2023-05-20</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/odoo/" itemprop="url" rel="index"><span itemprop="name">odoo</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>11k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>10 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="odoo实用配置与方法"><a href="#odoo实用配置与方法" class="headerlink" title="odoo实用配置与方法"></a>odoo实用配置与方法</h1><h2 id="float字段管理"><a href="#float字段管理" class="headerlink" title="float字段管理"></a>float字段管理</h2><ul>
<li>初始化小数decimal.precision记录，定义项目小数</li>
<li>float字段使用digits=dp.get_precision(‘id’)获取初始化的小数，便于统一修改</li>
</ul>
<span id="more"></span>

<h2 id="产品数量多单位转换示例"><a href="#产品数量多单位转换示例" class="headerlink" title="产品数量多单位转换示例"></a>产品数量多单位转换示例</h2><h3 id="描述："><a href="#描述：" class="headerlink" title="描述："></a>描述：</h3><p>   ODOO中的产品允许不同的业务有不同的单位，代码开发时需要注意单位换算</p>
<h3 id="代码示例"><a href="#代码示例" class="headerlink" title="代码示例"></a>代码示例</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">qty = line.product_uom._compute_quantity(line.product_uom_qty, line.product_id.uom_id)</span><br></pre></td></tr></table></figure>

<h3 id="方法"><a href="#方法" class="headerlink" title="方法"></a>方法</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">@api.multi</span><br><span class="line">def _compute_quantity(self, qty, to_unit, round=True, rounding_method=&#x27;UP&#x27;, raise_if_failure=True):</span><br><span class="line">    &quot;&quot;&quot; Convert the given quantity from the current UoM `self` into a given one</span><br><span class="line">        :param qty: the quantity to convert</span><br><span class="line">        :param to_unit: the destination UoM record (uom.uom)</span><br><span class="line">        :param raise_if_failure: only if the conversion is not possible</span><br><span class="line">            - if true, raise an exception if the conversion is not possible (different UoM category),</span><br><span class="line">            - otherwise, return the initial quantity</span><br><span class="line">    &quot;&quot;&quot;</span><br><span class="line">    if not self:</span><br><span class="line">        return qty</span><br><span class="line">    self.ensure_one()</span><br><span class="line">    if self.category_id.id != to_unit.category_id.id:</span><br><span class="line">        if raise_if_failure:</span><br><span class="line">            raise UserError(_(&#x27;The unit of measure %s defined on the order line doesn\&#x27;t belong to the same category than the unit of measure %s defined on the product. Please correct the unit of measure defined on the order line or on the product, they should belong to the same category.&#x27;) % (self.name, to_unit.name))</span><br><span class="line">        else:</span><br><span class="line">            return qty</span><br><span class="line">    amount = qty / self.factor</span><br><span class="line">    if to_unit:</span><br><span class="line">        amount = amount * to_unit.factor</span><br><span class="line">        if round:</span><br><span class="line">            amount = tools.float_round(amount, precision_rounding=to_unit.rounding, rounding_method=rounding_method)</span><br><span class="line">    return amount</span><br></pre></td></tr></table></figure>
<h3 id="说明"><a href="#说明" class="headerlink" title="说明"></a>说明</h3><p>   该方法使用时，需要实例化，且单例操作；待转换的单位(self), 将数量转为另一个单位对应的产品数量</p>
<p>   参数释义：qty-待转换数量，to_unit-转换单位，round-是否格式化小位数，rounding_method-格式化小数位时的小数精确度的计数保留法，raise_if_failure-发生异常时，是否抛出异常</p>
<p>   返回值：转换后的数量</p>
<h2 id="导入模板配置"><a href="#导入模板配置" class="headerlink" title="导入模板配置"></a>导入模板配置</h2><h3 id="描述"><a href="#描述" class="headerlink" title="描述"></a>描述</h3><p>odoo12版，在任一模块的导入界面，都可以配置其导入模板，在model.py文件中调用如下方法：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">@api.model</span><br><span class="line">def get_import_templates(self):</span><br><span class="line">&quot;&quot;&quot;获取导入模板&quot;&quot;&quot;</span><br><span class="line"># TODO 根据上下文信息，返回不同的Excel</span><br><span class="line">return [&#123;</span><br><span class="line">&#x27;label&#x27;: &#x27;产品的导入模板&#x27;,</span><br><span class="line">&#x27;template&#x27;: &#x27;/fr_base/static/xls/product_template.xls&#x27;</span><br><span class="line">&#125;]</span><br></pre></td></tr></table></figure>

<h2 id="会记多币种转换示例"><a href="#会记多币种转换示例" class="headerlink" title="会记多币种转换示例"></a>会记多币种转换示例</h2><h3 id="描述-1"><a href="#描述-1" class="headerlink" title="描述"></a>描述</h3><p>   业务单据中有不同的币种转换时，用以下方法</p>
<h3 id="代码示例-1"><a href="#代码示例-1" class="headerlink" title="代码示例"></a>代码示例</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">aml_dict[&#x27;debit&#x27;] = statement_currency._convert(aml_dict[&#x27;debit&#x27;] / st_line_currency_rate, company_currency, company, date)</span><br><span class="line">aml_dict[&#x27;credit&#x27;] = statement_currency._convert(aml_dict[&#x27;credit&#x27;] / st_line_currency_rate, company_currency, company, date)</span><br></pre></td></tr></table></figure>

<h3 id="方法-1"><a href="#方法-1" class="headerlink" title="方法"></a>方法</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">def _convert(self, from_amount, to_currency, company, date, round=True):</span><br><span class="line">    &quot;&quot;&quot;Returns the converted amount of ``from_amount``from the currency</span><br><span class="line">       ``self`` to the currency ``to_currency`` for the given ``date`` and</span><br><span class="line">       company.</span><br><span class="line"></span><br><span class="line">       :param company: The company from which we retrieve the convertion rate</span><br><span class="line">       :param date: The nearest date from which we retriev the conversion rate.</span><br><span class="line">       :param round: Round the result or not</span><br><span class="line">    &quot;&quot;&quot;</span><br><span class="line">    self, to_currency = self or to_currency, to_currency or self</span><br><span class="line">    assert self, &quot;convert amount from unknown currency&quot;</span><br><span class="line">    assert to_currency, &quot;convert amount to unknown currency&quot;</span><br><span class="line">    assert company, &quot;convert amount from unknown company&quot;</span><br><span class="line">    assert date, &quot;convert amount from unknown date&quot;</span><br><span class="line">    # apply conversion rate</span><br><span class="line">    if self == to_currency:</span><br><span class="line">        to_amount = from_amount</span><br><span class="line">    else:</span><br><span class="line">        to_amount = from_amount * self._get_conversion_rate(self, to_currency, company, date)</span><br><span class="line">    # apply rounding</span><br><span class="line">    return to_currency.round(to_amount) if round else to_amount</span><br></pre></td></tr></table></figure>
<h3 id="说明-1"><a href="#说明-1" class="headerlink" title="说明"></a>说明</h3><p>   该方法使用时，需要实例化，且单例操作；待转换的币种(self), 将金额转为指定公司指定时间(实时汇率)另一个币种对应的金额</p>
<p>   参数释义：from_amount-待转换金额，to_currency-转换币种，company-公司，date-日期，round-是否格式化小位数</p>
<p>   返回值：转换后的金额</p>
<h2 id="金额或产品数量之间比较"><a href="#金额或产品数量之间比较" class="headerlink" title="金额或产品数量之间比较"></a>金额或产品数量之间比较</h2><h3 id="描述-2"><a href="#描述-2" class="headerlink" title="描述"></a>描述</h3><p>   当产品数量、金额在相同的单位、汇率下比较时，用ODOO提供的以下工具比较，避免因小数位不同而带来的错误结果</p>
<h3 id="代码示例-2"><a href="#代码示例-2" class="headerlink" title="代码示例"></a>代码示例</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">from odoo.tools import float_compare, float_round, float_repr, float_is_zero</span><br><span class="line">float_compare(total_debit, total_credit, precision_rounding=digits_rounding_precision)</span><br></pre></td></tr></table></figure>
<h3 id="函数"><a href="#函数" class="headerlink" title="函数"></a>函数</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">def float_compare(value1, value2, precision_digits=None, precision_rounding=None):</span><br><span class="line">    &quot;&quot;&quot;Compare ``value1`` and ``value2`` after rounding them according to the</span><br><span class="line">       given precision. A value is considered lower/greater than another value</span><br><span class="line">       if their rounded value is different. This is not the same as having a</span><br><span class="line">       non-zero difference!</span><br><span class="line">       Precision must be given by ``precision_digits`` or ``precision_rounding``,</span><br><span class="line">       not both!</span><br><span class="line"></span><br><span class="line">       Example: 1.432 and 1.431 are equal at 2 digits precision,</span><br><span class="line">       so this method would return 0</span><br><span class="line">       However 0.006 and 0.002 are considered different (this method returns 1)</span><br><span class="line">       because they respectively round to 0.01 and 0.0, even though</span><br><span class="line">       0.006-0.002 = 0.004 which would be considered zero at 2 digits precision.</span><br><span class="line"></span><br><span class="line">       Warning: ``float_is_zero(value1-value2)`` is not equivalent to</span><br><span class="line">       ``float_compare(value1,value2) == 0``, as the former will round after</span><br><span class="line">       computing the difference, while the latter will round before, giving</span><br><span class="line">       different results for e.g. 0.006 and 0.002 at 2 digits precision.</span><br><span class="line"></span><br><span class="line">       :param int precision_digits: number of fractional digits to round to.</span><br><span class="line">       :param float precision_rounding: decimal number representing the minimum</span><br><span class="line">           non-zero value at the desired precision (for example, 0.01 for a</span><br><span class="line">           2-digit precision).</span><br><span class="line">       :param float value1: first value to compare</span><br><span class="line">       :param float value2: second value to compare</span><br><span class="line">       :return: (resp.) -1, 0 or 1, if ``value1`` is (resp.) lower than,</span><br><span class="line">           equal to, or greater than ``value2``, at the given precision.</span><br><span class="line">    &quot;&quot;&quot;</span><br><span class="line">    rounding_factor = _float_check_precision(precision_digits=precision_digits,</span><br><span class="line">                                             precision_rounding=precision_rounding)</span><br><span class="line">    value1 = float_round(value1, precision_rounding=rounding_factor)</span><br><span class="line">    value2 = float_round(value2, precision_rounding=rounding_factor)</span><br><span class="line">    delta = value1 - value2</span><br><span class="line">    if float_is_zero(delta, precision_rounding=rounding_factor): return 0</span><br><span class="line">    return -1 if delta &lt; 0.0 else 1</span><br></pre></td></tr></table></figure>

<h3 id="说明-2"><a href="#说明-2" class="headerlink" title="说明"></a>说明</h3><p>   函数将比较的两个值，先以相同的精度四舍五入，然后再比较大小；precision_digits-精度，precision_rounding-小数精度只能输入且必须输入任意一个</p>
<p>   参数释义：value1-待转换金额，value2-转换币种，precision_digits-精度(正整数)，precision_rounding-小数精度(浮点型：0.01)</p>
<p>   返回值：-1-小于，0-等于，1-大于</p>
<h2 id="短信配置示例-福人"><a href="#短信配置示例-福人" class="headerlink" title="短信配置示例(福人)"></a>短信配置示例(福人)</h2><h3 id="说明-3"><a href="#说明-3" class="headerlink" title="说明"></a>说明</h3><p>   在需要发送短信的业务代码位置，添加如下代码：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">self.env[&#x27;fr.sms.info&#x27;].sms_post([&#123;</span><br><span class="line">    &#x27;template_id&#x27;: self.env.ref(&#x27;tmplate.external_id&#x27;).id,    # 短信模板</span><br><span class="line">    &#x27;model_id&#x27;: obj._name,    # 发送短信关联的模型的名称</span><br><span class="line">    &#x27;res_id&#x27;: obj.id,    # 发送短信关联的模型的id</span><br><span class="line">    &#x27;name&#x27;: &#x27;&#x27;,    # 收信人名称</span><br><span class="line">    &#x27;phone&#x27;: &#x27;&#x27;,    # 收信人电话号码</span><br><span class="line">&#125;, ...])</span><br></pre></td></tr></table></figure>

<h3 id="注意"><a href="#注意" class="headerlink" title="注意"></a>注意</h3><p>   一个短信业务一个模板</p>
<h2 id="ODOO-BUTTON-样式"><a href="#ODOO-BUTTON-样式" class="headerlink" title="ODOO BUTTON 样式"></a>ODOO BUTTON 样式</h2><h3 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">.btn-primary</span><br><span class="line">.btn-secondary</span><br><span class="line">.btn-success</span><br><span class="line">.btn-info</span><br><span class="line">.btn-warning</span><br><span class="line">.btn-danger</span><br><span class="line">.btn-light</span><br><span class="line">.btn-dark</span><br><span class="line">.btn-outline-primary</span><br><span class="line">.btn-outline-secondary</span><br><span class="line">.btn-outline-success</span><br><span class="line">.btn-outline-info</span><br><span class="line">.btn-outline-warning</span><br><span class="line">.btn-outline-danger</span><br><span class="line">.btn-outline-light</span><br><span class="line">.btn-outline-dark</span><br></pre></td></tr></table></figure>

<h2 id="Code-Knowledge"><a href="#Code-Knowledge" class="headerlink" title="Code Knowledge"></a>Code Knowledge</h2><h3 id="KanBan视图记录通用点击事件重定义"><a href="#KanBan视图记录通用点击事件重定义" class="headerlink" title="KanBan视图记录通用点击事件重定义"></a>KanBan视图记录通用点击事件重定义</h3><p>   当我们实现通过一个对象的看板视图，跳转到另一个对象的视图并加载满足特定条件的功能时，我们一般会在看板视图上添加对应的链接，调用后台的方法，然后返回窗口并跳转，但是我们只点击第一个对象的看板视图的非链接区域时，将没有任何作用(除非第一个对象绑定了它的form视图，比较的直观的例子：会记模块进去后的概览视图)</p>
<p>   解决办法如下：</p>
<ul>
<li>首先，在看板视图标签上，添加以下class<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">class=&quot;oe_kanban_global_click&quot;</span><br></pre></td></tr></table></figure></li>
<li>第二步，添加如下js<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">odoo.define(&#x27;fr_cloud.FrStorageReportKanBanExtend&#x27;, function (require) &#123;</span><br><span class="line">    &#x27;use strict&#x27;;</span><br><span class="line"></span><br><span class="line">    var KanbanRecord = require(&#x27;web.KanbanRecord&#x27;);</span><br><span class="line"></span><br><span class="line">    KanbanRecord.include(&#123;</span><br><span class="line">        //--------------------------------------------------------------------------</span><br><span class="line">        // Private</span><br><span class="line">        //--------------------------------------------------------------------------</span><br><span class="line"></span><br><span class="line">        /**</span><br><span class="line">         * @override</span><br><span class="line">         * @private</span><br><span class="line">         */</span><br><span class="line">        _openRecord: function () &#123;</span><br><span class="line">            // 判断当前视图的model</span><br><span class="line">            if (this.modelName === &#x27;fr.storage.report&#x27;) &#123;</span><br><span class="line">                //将当前视图的record点击事件绑定到自己想要的事件</span><br><span class="line">                this.$(&#x27;a&#x27;).first().click();</span><br><span class="line">            &#125; else &#123;</span><br><span class="line">                this._super.apply(this, arguments);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;);</span><br><span class="line"></span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure></li>
<li>最后，当然是记得将js文件在xml、manifest文件中申明</li>
</ul>
<h3 id="ODOO多线程游标获取"><a href="#ODOO多线程游标获取" class="headerlink" title="ODOO多线程游标获取"></a>ODOO多线程游标获取</h3><p>   ODOO多线程在使用数据库游标时，直接传参，则游标不能用。报错信息是，游标已关闭，不能使用。所以在写多线程方法时，需要在子线程中，重新获取新的游标和环境变量。获取方法如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">def new_thread_write_obj(db_name, uid, model, model_id):</span><br><span class="line">    &quot;&quot;&quot;</span><br><span class="line">    注册新的游标和环境变量并访问odoo实例方法</span><br><span class="line">    :param: db_name 数据库名称</span><br><span class="line">    :param: uid 当前登录用户</span><br><span class="line">    :param: model 导入向导的model名</span><br><span class="line">    :param: model_id 导入向导的model的实例id</span><br><span class="line">    :return: None</span><br><span class="line">    &quot;&quot;&quot;</span><br><span class="line">    threading.current_thread().dbname = db_name</span><br><span class="line">    # 通过odoo方法注册数据库对象</span><br><span class="line">    registry = odoo.registry(db_name)</span><br><span class="line">    # 初始一个新的环境变量，并获取游标</span><br><span class="line">    with api.Environment.manage(), registry.cursor() as cr:</span><br><span class="line">        # 将环境变量与游标绑定</span><br><span class="line">        env = api.Environment(cr, uid, &#123;&#125;)</span><br><span class="line">        # 通过新的环境变量，访问odoo对象池里面的对象</span><br><span class="line">        model_obj = env[model]</span><br><span class="line">        model_record = model_obj.browse([model_id])</span><br><span class="line">        model_record._write_obj()</span><br></pre></td></tr></table></figure>
<p>其中，model，和model_id是自定义参数</p>
<h3 id="JS调用后端action之后，如何获取action的返回值？"><a href="#JS调用后端action之后，如何获取action的返回值？" class="headerlink" title="JS调用后端action之后，如何获取action的返回值？"></a>JS调用后端action之后，如何获取action的返回值？</h3><p>   ODOO中，js使用do_action方法弹出向导时，可以设置其on_close属性，获取其对应的返回值，并做进一步处理。在12中，使用方法如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">//js 文件中的方法</span><br><span class="line">_onImportAttachment: function (event) &#123;</span><br><span class="line">           var self = this;</span><br><span class="line">           if (event) &#123;</span><br><span class="line">               event.stopPropagation();</span><br><span class="line">           &#125;</span><br><span class="line">           // 调用do_action</span><br><span class="line">           this.do_action(&#123;</span><br><span class="line">               type: &#x27;ir.actions.act_window&#x27;,</span><br><span class="line">               res_model: &#x27;base.import.attachment&#x27;,</span><br><span class="line">               views: [[false, &#x27;form&#x27;]],</span><br><span class="line">               target: &#x27;new&#x27;,</span><br><span class="line">               context: &#123;default_model: this.modelName&#125;</span><br><span class="line">           &#125;, &#123;</span><br><span class="line">               // 当弹出窗口关闭时，获取后端方法返回值判断，并进一步处理</span><br><span class="line">               on_close: function (result) &#123;</span><br><span class="line">                   if (result &amp;&amp; (result.warning || result.notify)) &#123;</span><br><span class="line">                       var warning_data = result.warning;</span><br><span class="line">                       var notify_data = result.notify;</span><br><span class="line">                       if (warning_data) &#123;</span><br><span class="line">                           self.do_warn(warning_data.title, warning_data.message, warning_data.sticky, warning_data.className)</span><br><span class="line">                       &#125;</span><br><span class="line">                       if (notify_data) &#123;</span><br><span class="line">                           self.do_notify(notify_data.title, notify_data.message, notify_data.sticky, notify_data.className)</span><br><span class="line">                       &#125;</span><br><span class="line">    </span><br><span class="line">                   &#125;</span><br><span class="line">               &#125;</span><br><span class="line">           &#125;)</span><br><span class="line">       &#125;</span><br></pre></td></tr></table></figure>
<p>后端方法返回的值，需要特殊的封装：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">@api.multi</span><br><span class="line">    def action_confirm(self):</span><br><span class="line">        &quot;&quot;&quot;</span><br><span class="line">        压缩包处理顺序</span><br><span class="line">        1.前端传入后台的文件数据已被转为base64字符串，所以，首先应将base64转为文件二进制流</span><br><span class="line">        2.读取压缩包数据，并判断每个子文件命名的有效性</span><br><span class="line">        3.将有效的文件写入对应的字段</span><br><span class="line">        :return code: 200</span><br><span class="line">                invalidList</span><br><span class="line">                noResultList</span><br><span class="line">        &quot;&quot;&quot;</span><br><span class="line">        # TODO 支持更多的压缩类型；文件的大小限制变为可配置</span><br><span class="line">        self.ensure_one()</span><br><span class="line">        guess_valid = self.guess_attachment_type()</span><br><span class="line">        if guess_valid:</span><br><span class="line">            return guess_valid</span><br><span class="line">        else:</span><br><span class="line">            try:</span><br><span class="line">                new_t = threading.Thread(target=new_thread_write_obj, args=(self._cr.dbname, self._uid,</span><br><span class="line">                                                                            self._name,</span><br><span class="line">                                                                            self.id,))</span><br><span class="line">                new_t.setDaemon(True)</span><br><span class="line">                new_t.start()</span><br><span class="line">            except Exception as E:</span><br><span class="line">                return self._write_obj()</span><br><span class="line">        # 返回内容需要封装在infos属性中</span><br><span class="line">        return &#123;</span><br><span class="line">            &#x27;type&#x27;: &#x27;ir.actions.act_window_close&#x27;,</span><br><span class="line">            &#x27;infos&#x27;: &#123;</span><br><span class="line">                &#x27;notify&#x27;: &#123;</span><br><span class="line">                    &#x27;title&#x27;: _(&#x27;系统提示！&#x27;),</span><br><span class="line">                    &#x27;message&#x27;: _(&#x27;由于附件处理比较耗时，已将任务转移到后台处理。完成后，将第一时间通知您。&#x27;),</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br></pre></td></tr></table></figure>

<h3 id="ODOO方法中，如何手动发送系统消息（通过odooBot发送私信）？"><a href="#ODOO方法中，如何手动发送系统消息（通过odooBot发送私信）？" class="headerlink" title="ODOO方法中，如何手动发送系统消息（通过odooBot发送私信）？"></a>ODOO方法中，如何手动发送系统消息（通过odooBot发送私信）？</h3><p>   当某些后台通知需要使用系统通知时，可以通过odoo自带的机器人(12版以前的超级用户，其user_id为1)发送私信，使用方法如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">def _send_sys_info(self, result_list, no_result_list, invalid_list):</span><br><span class="line">        odoobot_id, channel_info = self.get_odoobot_channel()</span><br><span class="line">        channel_info.with_context(mail_create_nosubscribe=True).sudo().message_post(</span><br><span class="line">            body=f&quot;&quot;&quot;&lt;h5&gt;您的后台导入附件已处理完成&lt;/h5&gt;</span><br><span class="line">                        &lt;p&gt;完成任务总数&#123;len(result_list)&#125;&lt;/p&gt;</span><br><span class="line">                        &lt;p&gt;未匹配任务总数&#123;len(no_result_list)&#125;&lt;/p&gt;</span><br><span class="line">                        &lt;p&gt;无效的任务总数&#123;len(invalid_list)&#125;&lt;/p&gt;</span><br><span class="line">                &quot;&quot;&quot;,</span><br><span class="line">            message_type=&#x27;comment&#x27;,</span><br><span class="line">            subtype=&#x27;mail.mt_comment&#x27;,</span><br><span class="line">            author_id=odoobot_id</span><br><span class="line">        )</span><br><span class="line"></span><br><span class="line">def get_odoobot_channel(self):</span><br><span class="line">    &quot;&quot;&quot;获取OdooBot的私信信息，如果没有，则创建一个&quot;&quot;&quot;</span><br><span class="line">    odoobot_id = self.env[&#x27;ir.model.data&#x27;].xmlid_to_res_id(&quot;base.partner_root&quot;)</span><br><span class="line">    channel_record = self.env[&#x27;mail.channel&#x27;].search([(&#x27;channel_type&#x27;, &#x27;=&#x27;, &#x27;chat&#x27;), (&#x27;channel_partner_ids&#x27;, &#x27;in&#x27;, [odoobot_id])])</span><br><span class="line">    if not channel_record:</span><br><span class="line">        channel_record = self.env[&#x27;mail.channel&#x27;].init_odoobot()</span><br><span class="line">    return odoobot_id, channel_record</span><br></pre></td></tr></table></figure>

<h3 id="js报找不到tree视图类型的错误"><a href="#js报找不到tree视图类型的错误" class="headerlink" title="js报找不到tree视图类型的错误"></a>js报找不到tree视图类型的错误</h3><p>   将tree换为list就可以了</p>
<h3 id="笑脸交互方式为："><a href="#笑脸交互方式为：" class="headerlink" title="笑脸交互方式为："></a>笑脸交互方式为：</h3><p>   在py文件的方法中，返回：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">return &#123;</span><br><span class="line">    &#x27;effect&#x27;: &#123;</span><br><span class="line">        &#x27;fadeout&#x27;: &#x27;slow&#x27;,</span><br><span class="line">        &#x27;message&#x27;: &#x27;月结完成&#x27;,</span><br><span class="line">        &#x27;type&#x27;: &#x27;rainbow_man&#x27;,</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>二扬
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://eryangz.gitee.io/20210605/odoo%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%96%B9%E6%B3%95/" title="odoo实用配置与方法">https://eryangz.gitee.io/20210605/odoo实用配置与方法/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/odoo/" rel="tag"><i class="fa fa-tag"></i> odoo</a>
              <a href="/tags/%E7%AC%91%E8%84%B8%E4%BA%A4%E4%BA%92/" rel="tag"><i class="fa fa-tag"></i> 笑脸交互</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/20210529/mqtt%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA(emqx)/" rel="prev" title="mqtt服务器搭建(emqx)">
      <i class="fa fa-chevron-left"></i> mqtt服务器搭建(emqx)
    </a></div>
      <div class="post-nav-item">
    <a href="/20210621/nginx%E9%85%8D%E7%BD%AEodoo80%E7%AB%AF%E5%8F%A3%E8%AE%BF%E9%97%AE/" rel="next" title="nginx配置odoo80端口访问">
      nginx配置odoo80端口访问 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#odoo%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%96%B9%E6%B3%95"><span class="nav-text">odoo实用配置与方法</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#float%E5%AD%97%E6%AE%B5%E7%AE%A1%E7%90%86"><span class="nav-text">float字段管理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%A7%E5%93%81%E6%95%B0%E9%87%8F%E5%A4%9A%E5%8D%95%E4%BD%8D%E8%BD%AC%E6%8D%A2%E7%A4%BA%E4%BE%8B"><span class="nav-text">产品数量多单位转换示例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8F%8F%E8%BF%B0%EF%BC%9A"><span class="nav-text">描述：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B"><span class="nav-text">代码示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%96%B9%E6%B3%95"><span class="nav-text">方法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%AF%B4%E6%98%8E"><span class="nav-text">说明</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF%E9%85%8D%E7%BD%AE"><span class="nav-text">导入模板配置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8F%8F%E8%BF%B0"><span class="nav-text">描述</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BC%9A%E8%AE%B0%E5%A4%9A%E5%B8%81%E7%A7%8D%E8%BD%AC%E6%8D%A2%E7%A4%BA%E4%BE%8B"><span class="nav-text">会记多币种转换示例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8F%8F%E8%BF%B0-1"><span class="nav-text">描述</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B-1"><span class="nav-text">代码示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%96%B9%E6%B3%95-1"><span class="nav-text">方法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%AF%B4%E6%98%8E-1"><span class="nav-text">说明</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%87%91%E9%A2%9D%E6%88%96%E4%BA%A7%E5%93%81%E6%95%B0%E9%87%8F%E4%B9%8B%E9%97%B4%E6%AF%94%E8%BE%83"><span class="nav-text">金额或产品数量之间比较</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8F%8F%E8%BF%B0-2"><span class="nav-text">描述</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B-2"><span class="nav-text">代码示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%87%BD%E6%95%B0"><span class="nav-text">函数</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%AF%B4%E6%98%8E-2"><span class="nav-text">说明</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%9F%AD%E4%BF%A1%E9%85%8D%E7%BD%AE%E7%A4%BA%E4%BE%8B-%E7%A6%8F%E4%BA%BA"><span class="nav-text">短信配置示例(福人)</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%AF%B4%E6%98%8E-3"><span class="nav-text">说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B3%A8%E6%84%8F"><span class="nav-text">注意</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#ODOO-BUTTON-%E6%A0%B7%E5%BC%8F"><span class="nav-text">ODOO BUTTON 样式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B"><span class="nav-text">示例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Code-Knowledge"><span class="nav-text">Code Knowledge</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#KanBan%E8%A7%86%E5%9B%BE%E8%AE%B0%E5%BD%95%E9%80%9A%E7%94%A8%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6%E9%87%8D%E5%AE%9A%E4%B9%89"><span class="nav-text">KanBan视图记录通用点击事件重定义</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ODOO%E5%A4%9A%E7%BA%BF%E7%A8%8B%E6%B8%B8%E6%A0%87%E8%8E%B7%E5%8F%96"><span class="nav-text">ODOO多线程游标获取</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#JS%E8%B0%83%E7%94%A8%E5%90%8E%E7%AB%AFaction%E4%B9%8B%E5%90%8E%EF%BC%8C%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96action%E7%9A%84%E8%BF%94%E5%9B%9E%E5%80%BC%EF%BC%9F"><span class="nav-text">JS调用后端action之后，如何获取action的返回值？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ODOO%E6%96%B9%E6%B3%95%E4%B8%AD%EF%BC%8C%E5%A6%82%E4%BD%95%E6%89%8B%E5%8A%A8%E5%8F%91%E9%80%81%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF%EF%BC%88%E9%80%9A%E8%BF%87odooBot%E5%8F%91%E9%80%81%E7%A7%81%E4%BF%A1%EF%BC%89%EF%BC%9F"><span class="nav-text">ODOO方法中，如何手动发送系统消息（通过odooBot发送私信）？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#js%E6%8A%A5%E6%89%BE%E4%B8%8D%E5%88%B0tree%E8%A7%86%E5%9B%BE%E7%B1%BB%E5%9E%8B%E7%9A%84%E9%94%99%E8%AF%AF"><span class="nav-text">js报找不到tree视图类型的错误</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%AC%91%E8%84%B8%E4%BA%A4%E4%BA%92%E6%96%B9%E5%BC%8F%E4%B8%BA%EF%BC%9A"><span class="nav-text">笑脸交互方式为：</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="二扬"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">二扬</p>
  <div class="site-description" itemprop="description">念念不忘, 必有回响</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">26</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/EryangZzz" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;EryangZzz" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;" rel="noopener" target="_blank"><i class="fa fa-fw fa-github-alt"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="/1289256052" title="QQ → 1289256052"><i class="fa fa-fw fa-qq"></i>QQ</a>
      </span>
      <span class="links-of-author-item">
        <a href="/1289256052@qq.com" title="E-Mail → 1289256052@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



<script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
<div class="widget-wrap">
    <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=110 src="//music.163.com/outchain/player?type=0&id=8435349308&auto=1&height=66"></iframe>
    <h3 class="widget-title">标签云</h3>
    <div id="myCanvasContainer" class="widget tagcloud">
        <canvas width="250" height="250" id="resCanvas" style="width=100%">
            <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/emqx/" rel="tag">emqx</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flask/" rel="tag">flask</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/js/" rel="tag">js</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/metaclass/" rel="tag">metaclass</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mqtt/" rel="tag">mqtt</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nginx/" rel="tag">nginx</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/odoo/" rel="tag">odoo</a><span class="tag-list-count">10</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/odoo%E5%89%8D%E7%AB%AF/" rel="tag">odoo前端</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/odoo%E9%83%A8%E7%BD%B2/" rel="tag">odoo部署</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/office%E9%A2%84%E8%A7%88/" rel="tag">office预览</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pgsql/" rel="tag">pgsql</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pip%E6%BA%90/" rel="tag">pip源</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pyinstaller/" rel="tag">pyinstaller</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a><span class="tag-list-count">9</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/re/" rel="tag">re</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rtsp/" rel="tag">rtsp</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time%E6%A8%A1%E5%9D%97/" rel="tag">time模块</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu/" rel="tag">ubuntu</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ubuntu%E6%BA%90/" rel="tag">ubuntu源</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%85%83%E7%B1%BB/" rel="tag">元类</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" rel="tag">多线程</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9C%8D%E5%8A%A1%E9%85%8D%E7%BD%AE/" rel="tag">服务配置</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" rel="tag">正则表达式</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%AC%91%E8%84%B8%E4%BA%A4%E4%BA%92/" rel="tag">笑脸交互</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%A7%86%E9%A2%91%E6%B5%81/" rel="tag">视频流</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/" rel="tag">设计模式</a><span class="tag-list-count">1</span></li></ul>
        </canvas>
    </div>
</div>




      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">二扬</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">105k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">1:35</span>
</div>



        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
 var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>





  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
